package com.hunliji.monitor.web.controller.app;

import com.hunliji.common.response.ResponseData;
import com.hunliji.monitor.manager.api.UserManager;
import com.hunliji.monitor.share.component.redis.RedisFacade;
import com.hunliji.monitor.web.facade.TestFacade;
import com.hunliji.monitor.web.model.vo.TestVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.UUID;

/**
 * @author xingfeng
 * @date 2018/11/26
 */
@Api(value = "测试控制器", tags = "测试app接口")
@RestController
@RequestMapping(value = "/appApi/test")
@Slf4j
public class TestAppController {


    @Resource
    private TestFacade testFacade;

    @Resource
    private UserManager userManager;

    @ApiOperation(value = "根据主键查询")
    @GetMapping(value = "/getById")
    public ResponseData<TestVO> getById(Long id) {
        //manager 调用
        userManager.findByToken("1111");
        return ResponseData.success(testFacade.getById(id));
    }

    @GetMapping("/testDistributeLock")
    public ResponseData testDistributeLock(){
        testFacade.testDistributeLock();
        return ResponseData.success(null);
    }

    @GetMapping("/testLog")
    public ResponseData testLog(){
        testFacade.testLog();
        return ResponseData.success(null);

    }


    @GetMapping("/testMq")
    public ResponseData testMq(){
        testFacade.testMq();
        return ResponseData.success(null);

    }

    @GetMapping("/testMqBatch")
    public ResponseData testMqBatch(){
        testFacade.testMqBatch();
        return ResponseData.success(null);
    }


    @GetMapping("/testMqOrder")
    public ResponseData testMqOrder(){
        testFacade.testMqOrder();
        return ResponseData.success(null);
    }
    @Resource
    private RedisFacade redisFacade;

    @GetMapping("/setAndGet")
    public ResponseData setAndGet(){
        redisFacade.set("username", UUID.randomUUID().toString());
        log.info(redisFacade.get("username"));
        return ResponseData.success(null);
    }
}
